package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()

	// 返回byte数组
	r.GET("/byte", func(context *gin.Context) {
		path := context.FullPath()
		fmt.Println(path)
		context.Writer.Write([]byte(path))
	})

	// 返回string
	r.GET("/string", func(context *gin.Context) {
		path := context.FullPath()
		fmt.Println(path)
		context.Writer.WriteString(path)
	})

	// 返回Json
	r.GET("/json", func(context *gin.Context) {
		path := context.FullPath()
		fmt.Println(path)
		context.JSON(200, map[string]interface{}{
			"code":200,
			"msg":"ok",
			"data":"json",
		})
	})

	r.Run("127.0.0.1:8004")
}
